﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.Configuration;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class AppCode_Employee_PolicyDetails : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            if (Session["userNameEmployee"] == null)
            {
                Response.Redirect("../Home/HomePage.aspx");
            }
            else
            {
                String connect = WebConfigurationManager.ConnectionStrings["ConnectDatabase"].ToString();
                SqlConnection sqlConnect = new SqlConnection(connect);
                SqlDataAdapter sqlda = new SqlDataAdapter("select policyId,policyName,PolicyDesc,Amount,Emi,Policies.CompanyId,companyName from Policies join CompanyDetails " +
                                                           "on CompanyDetails.CompanyId=Policies.CompanyId", sqlConnect);
                DataSet ds = new DataSet();
                sqlda.Fill(ds);
                GridView1.DataSource = ds.Tables[0];
                GridView1.DataBind();

            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String connect = WebConfigurationManager.ConnectionStrings["ConnectDatabase"].ToString();
        SqlConnection sqlConnect = new SqlConnection(connect);
        SqlDataAdapter sqlda = new SqlDataAdapter("select policyId,policyName,PolicyDesc,Amount,Emi,Policies.CompanyId,companyName from Policies join CompanyDetails " +
                                                   "on CompanyDetails.CompanyId=Policies.CompanyId "+
                                                   "where policyname like '%"+txtSearch.Text+"%' or companyName like '%"+txtSearch.Text+"%'", sqlConnect);
        DataSet ds = new DataSet();
        sqlda.Fill(ds);
        GridView1.DataSource = ds.Tables[0];
        GridView1.DataBind();
    }
}